package com.itgaohe.controller;

import com.itgaohe.common.R;
import com.itgaohe.pojo.Student;
import com.itgaohe.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/Student")
public class StudentController {
    @Autowired
    private StudentService studentService;
    //增
    @PostMapping
    public R add(Student student){
        boolean save = studentService.save(student);
        return save?R.success("success"): R.error("error");
    }
    //删
    @DeleteMapping
    public R delete(@PathVariable Integer id){
        boolean b = studentService.removeById(id);
        return b?R.success("success"): R.error("error");
    }
    //改
    @PutMapping
    public R update(@RequestBody Student stu){
        boolean b = studentService.updateById(stu);
        return b?R.success("success"): R.error("error");
    }
}